from matplotlib import pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import numpy as np

#定义图像和三维格式坐标轴
fig = plt.figure()  #定义新的三维坐标轴
ax1 = plt.axes(projection='3d')

#定义三维数据
xx = np.arange(0,1,0.05)
yy = np.arange(0,1,0.05)
X, Y = np.meshgrid(xx, yy)
R = np.sin(X)
Z = np.exp(R+Y)


#作图
ax1.plot_surface(X,Y,Z)#,cmap='rainbow')
#ax3.contour(X,Y,Z, zdim='z',offset=-2，cmap='rainbow)   #等高线图，要设置offset，为Z的最小值
ax1.set_xlabel('X', color='b')
ax1.set_ylabel('Y', color='g')
ax1.set_zlabel('Z', color='r')
plt.draw()
plt.savefig('u.png')
plt.show()
